<template>
  <!-- <div v-show="currentIndex===analysisIndex&&analysisIndex>0"> -->
  <div class="analysis-main">
    <div class="analysis-left">
      <div class="item">
        <div class="vertical-bar"></div>
        <div class="item-content">
          <h3>大学录取概率分析</h3>
        </div>
      </div>
      <div>
        <div type="flex" class="proWap">
          <div span="12" class="probabilityWap">
            <div class="chart">
              <div style="width:120px; height:120px; margin:0 auto;" ref="probabilityChart"></div>
            </div>
            <div class="block-center">
              <p class="gray-ad text-center small-text">录取概率</p>
              <p class="energized text-center" :class="{'big-text':enrollAnalysis.probabilitie}">{{enrollAnalysis.probabilitie?enrollAnalysis.probabilitie+'%':'暂无数据'}}</p>
              <p class="dark text-center middle-text">{{enrollAnalysis.chongShouBao?enrollAnalysis.chongShouBao.name:''}}</p>
            </div>
          </div>
          <div span="12" style="position:relative;">
            <ul class="block-center--two">
              <li>
                <p class="gray-ad text-center small-text">你的分数</p>
                <p class="text-center middle-text">{{enrollAnalysis.score?enrollAnalysis.score:''}}</p>
              </li>
              <li>
                <p class="gray-ad text-center small-text">你的位次</p>
                <p class="text-center middle-text">{{enrollAnalysis.position?enrollAnalysis.position:''}}
                </p>
              </li>
            </ul>
          </div>
        </div>
        <div>
          <h3 class="text-center small-text gray-ad">说明</h3>
          <p>知涯志愿填报预测法,根据高校历年录取数据，结合招生计划趋势,大小年影响等.给出最合理的录取概率。</p>
        </div>
      </div>
    </div>

    <div class="analysis-right">
      <div class="item">
        <div class="vertical-bar"></div>
        <div class="item-content">
          <h3>最低位次历年趋势</h3>
        </div>
      </div>
      <div style="margin-bottom:50px;" v-show="enrollAnalysis.collegeScoreLines&&enrollAnalysis.collegeScoreLines.length > 0">
        <div class="seat-tip p15" type="flex" justify="space-around">
          <div><span>历年位次</span><span class="blue-circle"></span></div>
          <div><span>你的位次</span><span class="red-circle"></span></div>
        </div>
        <div class="chart">
          <div style="width:500px; height:250px" ref="seatChart"></div>
        </div>
        <div class="energized" style="font-size: 13px;padding-left: 15px;">最低位次波动范围： {{enrollAnalysis.minRank
          }}-{{enrollAnalysis.maxRank}}</div>
      </div>
      <no-content v-show="!enrollAnalysis.collegeScoreLines||enrollAnalysis.collegeScoreLines.length === 0" class="no-content" style="margin-top: 20px;"></no-content>
      <div class="item">
        <div class="vertical-bar"></div>
        <div class="item-content">
          <h3>最低分数历年趋势</h3>
        </div>
      </div>
      <div v-show="enrollAnalysis.collegeScores&&enrollAnalysis.collegeScores.length > 0">
        <div class="seat-tip p15" type="flex" justify="space-around">
          <div><span>历年分数</span><span class="blue-circle"></span></div>
          <div><span>你的分数</span><span class="red-circle"></span></div>
        </div>
        <div class="chart">
          <div style="width:500px; height:250px" ref="scoreChart"></div>
        </div>
      </div>
    </div>

    <no-content v-show="!enrollAnalysis.collegeScores||enrollAnalysis.collegeScores.length === 0" class="no-content" style="margin-top: 20px;"></no-content>
  </div>
</template>
<script>
import { api, chineSize, formatDate, getDateByYMD } from '@/utils'
import { mapState } from 'vuex'
import echarts from 'echarts/lib/echarts'
import _ from 'lodash'
import 'echarts/lib/chart/line'
import 'echarts/lib/chart/scatter'
import 'echarts/lib/chart/pie'
import 'echarts/lib/chart/bar'
export default {
  data () {
    return {
      data: {},
      currentIndex: 0,
      tabActiveIndex: 0,
      tabsData: [{ name: '简介', isClick: true }, { name: '专业', isClick: true }, { name: '招生简章', isClick: true }, { name: '招生计划', isClick: true }, { name: '分数线', isClick: true }],
      // tabsData: [],
      show: [false],
      pickerList: [{
        id: '',
        name: '全部'
      }, {
        id: 1001,
        name: '特色专业'
      }, {
        id: 1002,
        name: '国家重点'
      }],
      columns: [],
      pickerData: [],
      loading: false,
      finished: false,
      list: [],
      params: {
        page: 0,
        size: 15
      },
      text: '正在加载...',
      totalPages: 0,
      totalElements: 0,
      yearData: [],
      pickerYear: '',
      collegePickerData: [],
      collegePickerList: [],
      majorPickerData: [],
      majorPickerList: [],
      show1_: [false, false],
      show2_: [false, false, false],
      // curIndex: 0,
      collegeScoreLine: [],
      majorScoreLine: [],
      yearData1: [],
      yearData2: [],
      oldPickerData1: [],
      isPraise: false,
      praiseflag: true,
      info: {},
      isGaokaoTime: false,
      survey: ['1'],
      isShowDetail: [false, false],
      lookDetailName: ['查看详情', '查看详情'],
      enroll: false,
      analysisIndex: 0,
      enrollAnalysis: {}
    }
  },
  components: {
    echarts
  },
  computed: {
    ...mapState({
      userInfo: 'userInfo'
    }),
    years () {
      let years = []
      for (let i = 0; i < 4; i++) {
        years.unshift(formatDate(new Date(), 'yyyy') - i - 1)
      }
      return years
    }
  },
  methods: {
    init ({collegeId}) {
      console.log('接受----', collegeId)
      this.getEnrollAnalysis(collegeId)
    },
    initChartData (data) {
      let planData = []
      console.log('data--', this.years)
      this.years.forEach(el => {
        planData.push(0)
      })

      console.log('data--22', planData)
      let arrIndex = []
      data.forEach((item, index) => {
        this.years.forEach(el => {
          if (el === parseInt(item.year)) {
            let obj = {
              index: index,
              num: item.cnt
            }
            arrIndex.push(obj)
          }
        })
      })
      arrIndex.forEach(item => {
        planData.splice(item.index, 1, item.num)
      })

      return planData
    },
    lineChart (data, name, content, ref) {
      // data.collegeScoreLines
      let seatData = this.initChartData(data)
      let seatYears = JSON.parse(JSON.stringify(this.years))
      // '你的位次'
      seatYears.push(name)
      // data.position
      seatData.push(content)
      let option = {
        xAxis: {
          type: 'category',
          data: seatYears,
          axisLine: {
            // X轴的颜色
            lineStyle: {
              color: '#EAEAEA'
            }
          },
          axisLabel: {
            // 表示每间隔0个点显示一个标签
            interval: 0,
            textStyle: {
              color: '#AAAEB3'
            }
          }
        },
        yAxis: {
          type: 'value',
          axisLine: {
            // X轴的颜色
            lineStyle: {
              color: '#EAEAEA'
            }
          },
          axisLabel: {
            // 设置X轴字体颜色
            textStyle: {
              color: '#AAAEB3'
            }
          }
        },
        grid: {
          left: 15,
          right: 15,
          top: 30,
          bottom: 20,
          containLabel: true
        },
        series: [{
          data: seatData,
          type: 'line',
          symbolSize: 8,
          itemStyle: {
            normal: {
              // 拐点颜色
              color: function (params) {
                var colorList = ['#4BB8EE', '#4BB8EE', '#4BB8EE', '#4BB8EE', '#FE2828']
                return colorList[params.dataIndex]
              },
              borderWidth: 2,
              label: {
                show: true,
                position: 'top',
                formatter: function (c) {
                  if (parseInt(c.data) === 0) {
                    return '无数据'
                  } else {
                    return c.data
                  }
                }
              }
            }
          },
          // 折线粗细，阴影
          lineStyle: {
            normal: {
              color: '#4BB8EE',
              width: 2,
              shadowColor: '#4BB8EE',
              shadowBlur: 40,
              shadowOffsetY: 15
            }
          }
        }]
      }
      // this.$refs.seatChart
      let chartInstance = echarts.init(ref)
      chartInstance.setOption(option)
    },
    // 录取分析
    getEnrollAnalysis (collegeId) {
      this.$axios.get(api.getEnrollAnalysis, { params: { collegeId: collegeId } }).then(data => {
        if (data) {
          this.enrollAnalysis = data
          console.log(data.collegeScoreLines)
          // 位次趋势，分数
          if (data.collegeScoreLines.length > 0) {
            console.log('你的位次--')
            this.lineChart(data.collegeScoreLines, '你的位次', data.position, this.$refs.seatChart)
          }
          if (data.collegeScores.length > 0) {
            console.log('你的分数--')
            this.lineChart(data.collegeScores, '你的分数', data.score, this.$refs.scoreChart)
          }
          // 概率
          if (data.probabilitie !== null) {
            let probabilitie = parseFloat(data.probabilitie)
            let prOption = {
              series: [
                {
                  type: 'pie',
                  radius: ['100%', '95%'],
                  avoidLabelOverlap: false,
                  label: {
                    normal: {
                      show: true,
                      position: 'center',
                      formatter: '',
                      textStyle: {
                        fontSize: 24,
                        color: 'gray'
                      }
                    }
                  },
                  labelLine: {
                    normal: {
                      show: false
                    }
                  },
                  data: [
                    { value: probabilitie, name: '可上' },
                    { value: (100 - probabilitie), name: '不可上' }
                  ],
                  itemStyle: {
                    emphasis: {
                      shadowBlur: 10,
                      shadowOffsetX: 0,
                      shadowColor: 'rgba(0, 0, 0, 0.5)'
                    },
                    normal: {
                      color: function (params) {
                        // 自定义颜色
                        var colorList = [
                          '#4BB8EE', '#ECEDEF'
                          // 'red', 'blue'
                        ]
                        return colorList[params.dataIndex]
                      }
                    }
                  }
                }
              ]
            }
            let proChartInstance = echarts.init(this.$refs.probabilityChart)
            proChartInstance.setOption(prOption)
          }
        }
      }).catch(data => {
        // this.$toast('网络走丢了，请稍后重试！')
      })
    },
    lookDetail (index) {
      this.$set(this.isShowDetail, index, !this.isShowDetail[index])
      if (this.isShowDetail[index]) {
        this.lookDetailName[index] = '收起'
      } else {
        this.lookDetailName[index] = '查看详情'
      }
    },
    tabClick (i) {
      // console.log(this.currentIndex)
      if (this.currentIndex !== Number(i)) {
        let index = parseInt(i)
        this.currentIndex = index
        this.list = []
        this.text = '正在加载...'
        this.params.page = 0
        this.totalElements = 0
        this.pickerData = []
        this.columns = []
        this.enroll = false
        if (index === 1 + this.analysisIndex) {
          if (this.info.pageType === 'fromVMajorList') {
            if (this.tabsData[index].isClick) {
              this.collegePickerData = []
              this.collegePickerList = []
              this.$axios.get(api.queryScoreCondition).then(data => {
                let arr = []
                data.scienceAndArt.forEach((item, index) => {
                  let obj = {
                    id: item,
                    name: item
                  }
                  arr.push(obj)
                  data.scienceAndArt = arr
                })
                for (let x in data) {
                  this.collegePickerList.push(data[x])
                  this.collegePickerData.push(data[x][0])
                }
                this.collegePickerList[0].forEach((item, index) => {
                  if (item.id === this.userInfo.province.id) {
                    this.collegePickerData[0] = item
                    this.collegePickerList[0].defaultIndex = index
                  }
                })
                this.getMajorScoreLineByCollege()
              })
            } else {
              this.collegePickerList.map((cItem, cIndex) => {
                cItem.forEach((item, index) => {
                  if (item.id === this.collegePickerData[cIndex].id) {
                    this.collegePickerData[cIndex] = item
                    this.collegePickerList[cIndex].defaultIndex = index
                  }
                })
              })
            }
          } else if (!this.info.pageType || this.info.pageType !== 'volunteer') {
            this.columns[0] = this.pickerList
            console.log(1111)
            console.log(this.columns)
            // if (!_.isEmpty(this.oldPickerData1[0])) {
            // if (this.oldPickerData1[index - 1]) {
            if (!_.isEmpty(this.oldPickerData1[0])) {
              this.pickerDefaultIndex(this.oldPickerData1[0].id)
            } else {
              this.pickerData.push(this.pickerList[0])
            }
          }
        } else if (index === 2 + this.analysisIndex) {
          this.$set(this.columns, 0, this.yearData)
          if (!_.isEmpty(this.oldPickerData1[1])) {
            this.pickerDefaultIndex(this.oldPickerData1[index - 1].id)
          } else {
            // this.pickerDefaultIndex(Number(this.userInfo.startYear))
            this.pickerData.push(this.columns[0][0])
            this.$set(this.columns[0], 'defaultIndex', 0)
          }
          this.getData()
        } else if (index === 3 + this.analysisIndex) {
          this.getData()
        } else if (index === 4 + this.analysisIndex) {
          if (this.tabsData[index].isClick) {
            this.collegePickerData = []
            this.collegePickerList = []
            this.majorPickerData = []
            this.majorPickerList = []
            this.majorScoreLine = []
            this.$axios.get(api.queryScoreCondition).then(data => {
              let arr = []
              data.scienceAndArt.forEach((item, index) => {
                let obj = {
                  id: item,
                  name: item
                }
                arr.push(obj)
                data.scienceAndArt = arr
              })
              console.log(data.scienceAndArt)
              for (let x in data) {
                this.collegePickerList.push(data[x])
                this.collegePickerData.push(data[x][0])
                this.majorPickerList.push(data[x])
                this.majorPickerData.push(data[x][0])
              }
              this.majorPickerData.push(this.yearData[0])
              this.majorPickerList.push(this.yearData)
              this.collegePickerList[0].forEach((item, index) => {
                if (item.id === this.userInfo.province.id) {
                  this.collegePickerData[0] = item
                  this.collegePickerList[0].defaultIndex = index
                  // return this.collegePickerData
                }
              })
              _.map(this.majorPickerList, (arr, i) => {
                arr.forEach((item, index) => {
                  if (item.id === this.userInfo.province.id) {
                    this.majorPickerData[0] = item
                    this.majorPickerList[0].defaultIndex = index
                  }
                  // if (item.id === Number(this.userInfo.startYear)) {
                  //   this.majorPickerData[2] = item
                  //   this.majorPickerList[2].defaultIndex = index
                  // }
                })
              })
              this.majorPickerList[2].defaultIndex = 0
              console.log(this.majorPickerList)
              this.getCollegeScoreLine()
              this.getMajorScoreLine()
            })
          } else {
            let majorList = this.majorPickerList[2]
            for (let i = 0; i < majorList.length; i++) {
              if (majorList[i].id === this.majorPickerData[2].id) {
                this.$set(this.majorPickerList[2], 'defaultIndex', i)
              }
            }
          }
        }
        this.tabsData[index].isClick = false
        if (index === 0 + this.analysisIndex && this.tabsData[index].isClick) {
          this.getCollegeInfo()
        }
        if (index === 1 + this.analysisIndex && this.info.pageType !== 'fromVMajorList') {
          this.getData()
        }
      }
    },
    pickerDefaultIndex (type) {
      const columns = this.columns[0]
      columns.forEach((item, index) => {
        if (item.id === type) {
          this.pickerData.push(item)
          this.$set(this.columns[0], 'defaultIndex', index)
          //  return this.pickerData
        }
      })
    },
    /* 院校详情 */
    getCollegeInfo () {
      this.$axios.get(api.queryByCollegeId, { params: { collegeId: this.info.collegeId } }).then(data => {
        this.data = data.college
        this.info.title = data.college.name
        // this.isPraise = data.isPraise
        this.isPraise = data.isPraise
        // this.tabsData = [{ name: '简介', isClick: true }, { name: '专业', isClick: true }, { name: '招生简章', isClick: true }, { name: '招生计划', isClick: true }, { name: '分数线', isClick: true }]
      }).catch(data => {
        this.$toast('网络走丢了，请稍后重试！')
      })
    },
    /* picker按钮点击事件 */
    pickerChange (index) {
      // this.show = true
      this.show.splice(0, 0, true)
    },
    // 专业、招生简章、招生计划 下拉框
    onCancel () {
      // this.show = false
      this.show.splice(0, 0, false)
    },
    onConfirm (value, index) {
      // this.show = false
      this.show.splice(0, 0, false)
      this.pickerData[0] = value
      // console.log(this.$refs['picker'].curIndex)
      // this.pickerData.splice(this.$refs['picker'].curIndex, 1, value)
      if (this.currentIndex === 1) {
        this.oldPickerData1[0] = value
      } else if (this.currentIndex === 2) {
        this.oldPickerData1[1] = value
        /* } else if (this.currentIndex === 3) {
          this.oldPickerData1[2] = value */
      }
      this.params.page = 0
      this.list = []
      this.getData(value)
    },
    isShow (index, type) {
      if (type === 'college') {
        switch (index) {
          case 0:
            this.show1_.splice(0, 0, true)
            break
          case 1:
            this.show1_.splice(1, 0, true)
            break
        }
      } else if (type === 'major') {
        switch (index) {
          case 0:
            this.show2_.splice(0, 0, true)
            break
          case 1:
            this.show2_.splice(1, 0, true)
            break
          case 2:
            this.show2_.splice(2, 0, true)
            break
        }
      }
    },
    isHide (index, type) {
      if (type === 'college') {
        this.show1_.splice(0, 0, false)
        this.show1_.splice(1, 0, false)
      } else if (type === 'major') {
        this.show2_.splice(0, 0, false)
        this.show2_.splice(1, 0, false)
        this.show2_.splice(2, 0, false)
      }
    },
    // 获取数据
    getData (value) {
      let link
      // console.log(this.currentIndex)
      switch (this.currentIndex) {
        case (1 + this.analysisIndex):
          if (this.info.pageType === 'volunteer') {
            // console.log(this.info.pageType === 'volunteer')
            link = api.queryFirstCollegeMajor
            this.params = {
              page: this.params.page,
              size: this.params.size,
              collegeId: this.info.collegeId
            }
          } else if (this.info.pageType !== 'fromVMajorList') {
            // console.log(this.info.pageType !== 'fromVMajorList')
            link = api.queryCollegeMajorByCollegeIdAndMajorType
            this.params = {
              page: this.params.page,
              size: this.params.size,
              collegeId: this.info.collegeId,
              // majorTypeId: value ? value.id : ''
              majorTypeId: this.pickerData[0].id
            }
          }
          break
        case (2 + this.analysisIndex):
          link = api.queryEnrollGuideList
          this.params = {
            page: this.params.page,
            size: this.params.size,
            collegeId: this.info.collegeId,
            year: this.pickerData[0].id
          }
          break
        case (3 + this.analysisIndex):
          link = api.queryEnrollStudentPlan
          this.params = {
            collegeId: this.info.collegeId,
            year: this.yearData[0].id
          }
          break
      }
      this.$axios.get(link, { params: this.params }).then(data => {
        // this.$toast('data')
        if (!_.isEmpty(data)) {
          if (data.length > 0 || data.content.length > 0) {
            console.log(111)
            if (this.currentIndex === 1 + this.analysisIndex) {
              if (this.info.pageType !== 'volunteer') {
                data.content.forEach(item => {
                  item.desc = (item.type !== 0) ? `${chineSize[parseInt(item.type / 10)]}选${chineSize[item.type % 10]}` : ''
                })
              } else if (this.info.pageType === 'volunteer') {
                data.content.forEach(item => {
                  if (!item.chongShouBao) {
                    item.chongShouBao = {
                      id: 4,
                      name: '数据缺失'
                    }
                  }
                  // if (!item.probability) {
                  //   item.probability = 0
                  // }
                })
              }
            }
            if (this.currentIndex < 3 + this.analysisIndex || this.currentIndex === 4 + this.analysisIndex) {
              this.list = this.list.concat(data.content)
              this.totalPages = data.totalPages
              this.totalElements = data.totalElements
              // 加载状态结束
              this.loading = false
              // console.log(this.list.length)
              if (this.list.length > 0) {
                if (this.list.length >= this.totalElements) {
                  this.finished = true
                  this.text = '已加载全部数据'
                } else {
                  this.text = ''
                  this.finished = false
                }
              } else {
                this.text = '暂无数据'
              }
            } else {
              this.list = data
            }
          } else {
            console.log(222)
            this.list = []
            this.totalPages = 0
            this.totalElements = 0
            this.text = '暂无数据'
          }
        } else {
          // console.log(1111)
          this.list = []
          this.totalPages = 0
          this.totalElements = 0
          this.text = '暂无数据'
        }
        // console.log(this.list)
      }).catch(data => {
        console.log(data)
        this.text = '网络走丢了，请稍后重试！'
      })
    },
    // 院校分数线
    collegePickerChange (index) {
      this.curIndex = index
      this.isShow(index, 'college')
    },
    onScoreCancel () {
      this.isHide(this.curIndex, 'college')
    },
    onScoreConfirm (value, index) {
      this.isHide(this.curIndex, 'college')
      this.collegePickerData.splice(this.curIndex, 1, value)
      this.getCollegeScoreLine()
    },
    // 专业分数线
    majorPickerChange (index) {
      this.curIndex = index
      this.isShow(index, 'major')
    },
    onMajorCancel () {
      this.isHide(this.curIndex, 'major')
    },
    onMajorConfirm (value, index) {
      this.isHide(this.curIndex, 'major')
      this.majorPickerData.splice(this.curIndex, 1, value)
      this.majorScoreLine = []
      if (this.curIndex === 2) {
        // console.log(_.isEmpty(this.oldPickerData1[0]))
        // console.log(_.isEmpty(this.oldPickerData1[1]))
        if (_.isEmpty(this.oldPickerData1[0])) {
          this.oldPickerData1[0] = {}
        }
        if (_.isEmpty(this.oldPickerData1[1])) {
          this.oldPickerData1[1] = {}
        }
        this.oldPickerData1[2] = value
      }
      this.getMajorScoreLine()
    },
    // 获取院校分数线数据
    getCollegeScoreLine () {
      let params = {
        collegeId: this.info.collegeId,
        provinceId: this.collegePickerData[0].id,
        scienceAndArt: this.collegePickerData[1].id
      }
      this.$axios.get(api.queryCollegeScoreLine, { params: params }).then(data => {
        if (data || data.length > 0) {
          this.collegeScoreLine = data
        } else {
          this.collegeScoreLine = []
        }
      })
    },
    // 获取专业分数线数据
    getMajorScoreLine () {
      this.params = {
        collegeId: this.info.collegeId,
        provinceId: this.majorPickerData[0].id,
        scienceAndArt: this.majorPickerData[1].id,
        year: this.majorPickerData[2].id
      }
      this.$axios.get(api.queryMajorScoreLine, { params: this.params }).then(data => {
        if (data || data.length > 0) {
          this.majorScoreLine = this.majorScoreLine.concat(data)
        } else {
          this.majorScoreLine = []
        }
      })
    },
    // 获取专业下院校的分数线
    getMajorScoreLineByCollege () {
      let params = {
        collegeId: this.info.collegeId,
        provinceId: this.collegePickerData[0].id,
        scienceAndArt: this.collegePickerData[1].id,
        majorId: this.info.majorId
      }
      this.$axios.get(api.filterCollegeMajorScoreLine, { params: params }).then(data => {
        if (data.length > 0) {
          this.collegeScoreLine = data
        } else {
          this.collegeScoreLine = []
          this.text = '暂无数据'
        }
      }).catch(data => {
        this.text = '网络走丢了，请稍后重试！'
      })
    },
    onLoad () {
      // 异步更新数据
      setTimeout(() => {
        if (this.params.page + 1 < this.totalPages) {
          this.params.page++
          if (this.currentIndex === 4) {
            this.getMajorScoreLine()
          } else {
            this.getData()
            if (!this.info.schoolChoose) {
              this.list.forEach(el => {
                el.choose = false
              })
            }
          }
        }
      }, 500)
    },
    // 关注，添加备选库或者添加至志愿表
    onClickRight () {
      if (this.info.ifFillSchool) {
        if (!this.info.schoolChoose) {
          this.collectParams = {
            enrollBatch: {
              id: this.info.enrollBatchId
            },
            probability: this.info.probability,
            number: this.info.number,
            college: {
              id: this.info.collegeId
            },
            chongShouBao: this.info.chongShouBao
          }
          this.$axios.post(api.setWishCollege, this.collectParams).then(data => {
            this.info.schoolChoose = true
            setTimeout(() => {
              setTimeout(() => {
                this.$router.replace({
                  path: '/volunteer-fill-index'
                })
                this.$store.commit('setIsChange', true)
              }, 5)
            }, 5)
          }).catch(data => {
            this.$toast('网络走丢了，请稍后重试！')
          })
          // this.isAdd = true
        }
      } else if (this.info.pageType === 'volunteer' && !this.info.ifFillSchool) {
        this.$toast.loading({
          mask: true,
          duration: 0, // 持续展示 toast
          forbidClick: true
        })
        this.$axios.post(api.setFirstCollege, { college: { id: this.info.collegeId } }).then(data => {
          // let i = this.schoolSum
          this.info.schoolChoose = !this.info.schoolChoose
          if (this.info.schoolChoose) {
            // i++
            this.$store.commit('setSchoolMajorChoose', true)
          } else {
            // i--
            this.$store.commit('setSchoolMajorChoose', false)
            this.list.forEach(el => {
              el.choose = false
            })
            // console.log(this.list)
          }
          this.$toast.clear()
          // this.$store.commit('setSchoolSum', i)
        }).catch(data => {
          this.$toast('网络走丢了，请稍后重试！')
        })
      } else if (this.info.pageType === 'fromVMajorList') {
        this.$toast.loading({
          mask: true,
          duration: 0, // 持续展示 toast
          forbidClick: true
        })
        this.$axios.post(api.setFirstMajorCollege, { majorId: parseInt(this.info.majorId), collegeId: this.info.collegeId, enrollStudentPlansId: this.info.enrollStudentPlansId }).then(data => {
          this.info.schoolChoose = !this.info.schoolChoose
          this.$toast.clear()
        }).catch(data => {
          this.$toast('网络走丢了，请稍后重试！')
        })
      } else if (!this.info.ifFillSchool && !this.info.pageType) {
        this.$axios.get(api.setFavorite, { params: { type: 1, id: this.$route.query.collegeId } }).then(data => {
          this.isPraise = !this.isPraise
        }).catch(data => {
          this.$toast('网络走丢了，请稍后重试！')
        })
      }
    },
    // 加入备选库
    add (index, id) {
      // 延时点击
      if (this.praiseflag) {
        this.$axios.post(api.setFirstCollegeMajor, { studentPlansId: id, collegeId: this.info.collegeId }).then(data => {
          this.list[index].choose = !this.list[index].choose
        }).catch(data => {
          this.$toast('网络走丢了，请稍后重试！')
        })
      }
      this.praiseflag = false
      setTimeout(() => {
        this.praiseflag = true
      }, 500)
    }
  },
  activated () {
    if (this.info.pageType === 'fromVMajorList') {
      this.$store.commit('setFirstComeSchool', true)
    } else {
      this.$store.commit('setFirstComeSchool', false)
    }
    this.oneTime = 0
    let years = []
    for (let i = 0; i < 4; i++) {
      years.push({ id: formatDate(new Date(), 'yyyy') - i, name: formatDate(new Date(), 'yyyy') - i })
    }
    this.$set(this, 'yearData', years)
    this.info = this.$route.query
    this.text = '正在加载...'
    this.list = []
    if (this.info.pageType === 'fromVMajorList') {
      this.tabsData = [
        { name: '简介', isClick: true },
        { name: '分数线', isClick: true }
      ]
      this.$axios(api.getUserScore).then(data => {
        if (data) {
          let { startTime, endTime } = data
          if (startTime && endTime) {
            let time = new Date(getDateByYMD()).getTime()
            if (startTime <= time && endTime >= time) {
              this.isGaokaoTime = true
            }
          }
        }
      })
    }
    this.params.page = 0
    if (this.currentIndex === 0 || this.currentIndex === 1) {
      this.getCollegeInfo()
      if (this.currentIndex === 1 && !this.enroll) {
        this.getData()
      }
    } else {
      this.getData()
    }
    if (this.info.pageType === 'volunteer' || this.info.pageType === 'fromVMajorList') {
      this.analysisIndex = 1
    } else {
      this.analysisIndex = 0
    }
  }
}
</script>

<style scoped lang="scss">
.page {
  .analysis-main{
    display:flex;
    justify-content:space-between;
    .analysis-left{
      position:relative;
      width:200px;
    }
    .analysis-right{
      width:500px;
    }
  }

  > .college {
    margin: 0 15px;
    > .school-name {
      display: inherit;
      > span {
        margin-left: 10px;
      }
    }
    .title {
      > .item {
        justify-content: space-between;
        margin-bottom: 30px;
      }
    }
    .btn-years {
      background-color: #f7f7f7;
      color: gray;
      pointer-events: none;
      margin: 15px 5px 5px;
      width: 40%;
    }
    .enrollStudentPlan {
      margin-top: 10px;
    }
  }
  .container {
    .list {
      .major {
        min-height: 72px;
        height: auto;
        // border: 1px solid red;
        /* .badge {
          margin-right: 4px;
        } */
        .chooce-major {
          /* border: 1px solid red;
          margin: 0 -15px;
          z-index: 22; */
          > i {
            position: absolute;
            // right: 16px;
            right: 0;
            padding: 10px;
            margin-right: -10px;
            // border: 1px solid red;
          }
        }
        .detail {
          > p {
            font-size: 14px;
          }
        }
      }
      &.enroll-guide {
        .van-cell {
          box-shadow: none;
          padding-left: 0;
          padding-right: 0;
          a {
            font-size: 17px;
            text-decoration: underline;
            color: gray;
          }
          &:not(:last-child)::after {
            border-bottom: none;
          }
        }
      }
      .item-content {
        p {
          font-size: 17px;
          color: #494949;
          line-height: 28px;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 4;
          -webkit-box-orient: vertical;
          overflow: hidden;
          &.showAll {
            -webkit-line-clamp: inherit !important;
          }
        }
      }
      a.btn-detail {
        display: inline-block;
        width: 100%;
        margin-top: 8px;
        text-align: center;
        color: gray;
        > span {
          font-size: 16px;
        }
        .icon {
          transition: all linear 0.3s;
        }
        &.open {
          .icon-arrow-bottom {
            transform: rotate(0deg);
            display: inline-block;
          }
        }
        &.retract {
          .icon-arrow-bottom {
            transform: rotate(-180deg);
            display: inline-block;
          }
        }
      }
      /deep/ .van-collapse-item .van-cell {
        margin: 0px !important;
      }
      .contact-way {
        .btn-detail {
          display: inline !important;
          text-align: left !important;
        }
      }
    }
    .collegeInfo {
      .list {
        transition: all ease 0.5s;
      }
      .survey {
        margin-top: -10px;
      }
      .item {
        // padding: 15px 0 5px;
        padding: 25px 0 5px;
        h3 {
          color: #040404;
        }
      }
    }
    .table-wrap {
      margin-top: -10px;
      tr:first-child {
        td {
          // background-color: red;
          border-top-width: 0px;
        }
      }
    }
    .score {
      margin-top: 10px;
    }
  }
  /deep/ {
    /* .tab-wrap {
      justify-content: flex-start;
      > .tab-list {
        width: auto;
      }
      > .triped {
        left: -1px !important;
        min-width: 35px !important;
      }
    } */
    .van-tabs__wrap .van-tabs__line {
      left: 1px;
    }
    .van-tab {
      // flex: inherit;
    }
    .picker-wrap {
      width: 100%;
      display: inline-block;
      // border: 1px solid red;
      &.picker-fixed {
        background-color: #fff;
        position: fixed;
        z-index: 9999;
        margin-top: -10px;
      }
      .picker {
        .van-button {
          // width: 110px;
          position: relative;
        }
      }
    }
    .van-nav-bar__right {
      height: 46px;
      display: inline-block;
      .icon {
        font-size: 22px;
      }
    }
  }
  .list-wrap {
    padding-top: 50px;
  }
  table {
    width: 100%;
    thead {
      tr {
        color: #adadad;
        background-color: #f7f7f7;
        td {
          border: 1px solid #adadad;
          vertical-align: middle;
        }
      }
    }
    tbody {
      tr {
        td {
          border: 1px solid #adadad;
          color: #494949;
          text-align: center;
          vertical-align: middle;
          word-break: break-all;
        }
      }
    }
    td {
      padding: 10px 0;
      text-align: center;
      &.none {
        display: none;
      }
    }
  }
  .chart {
    // border: 1px solid yellow;
    > div {
      // border: 1px solid red;
      height: 160px;
      margin: auto 0;
    }
  }
  .proWap {
    margin-bottom: 10px;
    > .van-col {
      position: relative;
    }
    .probabilityWap {
      position:relative;
      // height: 160px;
    }
    ~ div {
      padding: 10px;
      background-color: #f7f7f7;
      border-radius: 10px;
      p {
        font-size: 14px;
        line-height: 27px;
        text-align: justify;
      }
    }
  }
  .block-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  .block-center--two{
    padding:20px 0;
    display:flex;
    align-items:center;
    justify-content: space-between;
    li{
      width:50%;
      display:flex;
      flex-direction: column;
    }
  }
  .small-text {
    font-size: 16px;
    line-height: 22px;
  }
  .middle-text {
    font-size: 18px;
    line-height: 28px;
  }
  .big-text {
    font-size: 24px;
    line-height: 33px;
  }
  .seat-tip {
    display: flex;
    justify-content: space-between;
    > div {
      display: flex;
      align-items: center;
    }
    .blue-circle,
    .red-circle {
      display: block;
      width: 10px;
      height: 10px;
      border-radius: 50%;
      margin-left: 5px;
      border: 2px solid #FE2828;
      background-color: transparent;
    }
    .blue-circle {
      border: 2px solid #4BB8EE;
    }
  }
}
</style>
